<template>
  <div>
    <div id="main"></div>
  </div>
</template>
<script>
export default {
  name: "c1",
  data() {
    return {
      mydata: [],
      mydata2: [],
    };
  },
  mounted() {
    this.groupByEnterprise();
  },
  methods: {
    groupByEnterprise() {
      this.$axios.get("enterprise/group").then((res) => {
        if (res.data.code == 200) {
          this.mydata = res.data.data.enterprises;
          this.mydata2 = res.data.data.enterprises2;
          this.getChar();
        }
      });
    },
    getChar() {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById("main"));
      var option;
      option = {
        title: {
          text: "入驻企业",
          subtext: "企业拥有的员工数",
          left: "center",
        },
        xAxis: {
          type: "category",
          data: this.mydata2,
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: this.mydata,
            type: "bar",
            barWidth: "40%",
          },
        ],
      };
      myChart.setOption(option);
    },
  },
};
</script>
<style scoped>
#main {
  border: 0px solid rgb(255, 0, 0);
  margin-left: -70px;
  margin-top: 20px;
  width: 3000px;
  height: 600px;
}
</style>
